package com.csp.base.jobconfig.listener;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.JobListener;
import com.csp.base.service.JobRunHistoryService;
import com.csp.base.utils.SpringUtil;

public class SimpleJobListener implements JobListener{
	
    @Override
    public String getName() {
        String name = getClass().getSimpleName();
        return name;
    }

    //准备执行
    @Override
    public void jobToBeExecuted(JobExecutionContext context) {
    }

    //执行被否决
    @Override
    public void jobExecutionVetoed(JobExecutionContext context) {
    }

    //执行结束(执行失败也会拦截到)
    @Override
    public void jobWasExecuted(JobExecutionContext context, JobExecutionException jobException) {
    	JobRunHistoryService runHistoryService = SpringUtil.getBean(JobRunHistoryService.class);
    	runHistoryService.recordRunHistoty(context, jobException);
    }
}